<?php
// +----------------------------------------------------------------------
//            -------------------------
//           /   / ----------------\  \
//          /   /             \  \
//         /   /              /  /
//        /   /    /-------------- /  /
//       /   /    /-------------------\  \
//      /   /                   \  \
//     /   /                     \  \
//    /   /                      /  /
//   /   /      /----------------------- /  /
//  /-----/      /---------------------------/
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://baimifan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Sage 2016/8/1  10:27
// +----------------------------------------------------------------------
namespace Service;
require_once COMMON_PATH.'phpqrcode/phpqrcode.php';

class QrcodeService {
    private static $imgPath='./Upload/imgs/';
    private static $rootPath='http://localhost/Upload/imgs/';
    function __construct($container) {
        $this->di=$container;
    }

    function produceQrcode($content){
        $errorCorrectionLevel = 'L';//容错级别
        $matrixPointSize = 6;//生成图片大小

        $filename=date('Ymdhis',time()).'_'.mt_rand().'.png';
        $path=self::$imgPath.$filename; //保存文件名
        $img = \QRcode::png($content, $path, $errorCorrectionLevel, $matrixPointSize, 2);
        return self::$rootPath.$filename;
    }
}